package com.x.redcube.model;

import com.alibaba.fastjson.JSON;
import com.x.redcube.util.Constant;
import com.x.redcube.util.DigestUtils;

import java.util.Map;

public class LianJiaRequest {
    private String companyCode = Constant.LIANJIA_USERNAME;
    private String seqNum;
    private String digest;
    private Map<String, String> content;

    public String getCompanyCode() {
        return companyCode;
    }

    public void setCompanyCode(String companyCode) {
        this.companyCode = companyCode;
    }

    public String getSeqNum() {
        return seqNum;
    }

    public void setSeqNum(String seqNum) {
        this.seqNum = seqNum;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    public Map<String, String> getContent() {
        return content;
    }

    public void setContent(Map<String, String> content) {
        if (content != null) {
            String json = JSON.toJSONString(content);
            System.out.println("json==========" + json);
            this.digest = DigestUtils.digest(Constant.LIANJIA_PASSWORD, json);
            this.content = content;
        }
    }

    public static void main(String[] args) {
        Map<String, String> map = new java.util.HashMap<String, String>();
        map.put("businessId", "1234567890");
        map.put("bscode", "0987654321");
        System.out.println("mapJson==========" + JSON.toJSONString(map));
        LianJiaRequest model = new LianJiaRequest();
        model.setContent(map);
        String digest = model.getDigest();
        System.out.println("digest==========" + digest);
        boolean flag = DigestUtils.verify(digest, Constant.LIANJIA_PASSWORD, JSON.toJSONString(map));
        System.out.println("flag==========" + flag);
    }

}
